package com.ele.client.activity.training;

import com.ele.client.ClientFactory;
import com.ele.client.activity.auth.LoginPlace;
import com.ele.client.util.UserHelper;
import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

public class TrainingActivity extends AbstractActivity implements TrainingView.Presenter {

	private ClientFactory clientFactory;
	private TrainingPlace place;
	private TrainingView view;

	public TrainingActivity(TrainingPlace place, ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
		this.place = place;
	}

	@Override
	public void start(AcceptsOneWidget container, EventBus eventBus) {
		if (UserHelper.getUser() == null) {
			UserHelper.setReferrer(place);
			clientFactory.getPlaceController().goTo(new LoginPlace(null));
		} else {
//			view = clientFactory.getTerminalView();
			view.setPresenter(this);
			container.setWidget(view.asWidget());

			load();
		}
	}

	private void load() {
		// TODO: add async part
	}
}
